﻿using ECommon;
using System.Threading.Tasks;

namespace LeanApp.Bll
{
    /// <summary>
    /// 邮件封装
    /// </summary>
    public class EmailBll
    {
        /// <summary>
        /// 异步发送邮件
        /// </summary>
        /// <param name="fromMailAddress">发送人邮箱地址</param>
        /// <param name="toMailAddress">接收人邮箱地址</param>
        /// <param name="emailUserNo">发送人邮箱账号</param>
        /// <param name="emailPwd">发送人邮箱密码</param>
        /// <param name="emailServer">发送人邮箱服务器</param>
        /// <param name="emailPort">发送人邮箱服务端口</param>
        /// <param name="subject">邮件主题</param>
        /// <param name="content">邮件内容</param>
        /// <param name="isSsl">是否采用安全链接发送</param>
        /// <param name="attachFilePath">邮件附件</param>
        /// <returns>异步任务</returns>
        public async Task SendEmail(string fromMailAddress, string toMailAddress, string emailUserNo, string emailPwd, string emailServer, int emailPort, string subject, string content, bool isSsl, string attachFilePath)
        {
            await Task.Run(() =>
            {
                EmailTool.SendEmail(fromMailAddress, toMailAddress, emailUserNo, emailPwd, emailServer, emailPort, subject, content, isSsl, attachFilePath);
            });
        }
    }
}
